<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
	<head>
		<title>Login Cuy</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <script src="<?php echo HTTP_SERVER; ?>js/jquery.js" type="text/javascript"></script>
        </head>
	<body>
<form id="wgt_user_login_form" name="wgt_user_login_form" action="<?php echo HTTP_SERVER; ?>?page=login&act=login-check" method="post">
    <p><label for="wgt_user_username">username: </label><input id="wgt_user_username" type="text" name="wgt_user_username"/></p>
    <p><label for="wgt_user_password">password: </label><input id="wgt_user_password" type="password" name="wgt_user_password"/></p>
    <p><input type="submit" name="submit" value="masuk"/></p>
    <p id="wgt_user_message" class="wgt_user_message"></p>
</form>
<script type="text/javascript">
$(function(){
    var wgt_user_login_result = function(data){
        if(data['result']) {
            window.location = '<?php echo HTTP_SERVER; ?>?page=user';
        } else {
            $('#wgt_user_message').html(data['message']).fadeIn();
        }
    };

    $('#wgt_user_login_form').submit(function(e){
        e.preventDefault();
        e.stopPropagation();

        $.post('<?php echo HTTP_SERVER; ?>?page=login&act=login-check', $('#wgt_user_login_form').serializeArray(), function(data){wgt_user_login_result(data);},"json");
    });

    $('#wgt_user_message').hide();
});
</script>
        </body>
</html>